package com.eling.elcms.travel.model;

import com.eling.elcms.basedoc.model.AdministrativeDivision;
import com.eling.elcms.basedoc.model.EnumSerializer;
import com.eling.elcms.community.model.Organization;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancer;
import com.eling.elcms.core.dao.annotation.CriteriaEnhancers;
import com.eling.elcms.core.dao.annotation.In;
import com.eling.elcms.core.dao.hibernate.search.EnumBridge;
import com.eling.elcms.core.model.BaseModel;
import com.eling.elcms.privilege.service.impl.CommonPrivilegeCriteriaEnhancer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.search.annotations.*;

import javax.persistence.*;

/** 
 * 旅居
 * 联盟单位
 * @author sunchenlong
 * 
 * 模型评审：新增模型，wulina 2016-09-02
 * 
 * */
@Entity
@Indexed
@Table(name = "travel_allianceorg")
@CriteriaEnhancers(criteriaEnhancers = {
		@CriteriaEnhancer(impl = CommonPrivilegeCriteriaEnhancer.class, parameter = "organization:organization") })
public class AllianceOrg extends BaseModel{

	private static final long serialVersionUID = 3815797964938418199L;

	@Id
	@DocumentId
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long pkAllianceOrg;
	
	/** 所属机构*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "pkOrganization")
    @IndexedEmbedded(depth = 1)
	private Organization organization;
	
	/** 名称*/
	@Field
	@Column(length = 40)
	private String name;
	
	/** 企业性质*/
	@Enumerated(EnumType.STRING)
	@Field
	@In
	@FieldBridge(impl = EnumBridge.class)
	private OrgOwnership orgOwnership;
	
	/** 省/市/区(县)*/
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="pkAddress")
	@IndexedEmbedded(depth = 1)
	private AdministrativeDivision address;
	
	/** 详细地址*/
	@Field
	@Column(length = 40)
	private String street;
	
	/** 负责人*/
	@Field
	@Column(length = 30)
	private String principal;
	
	/** 联系电话*/
	@Field
	@Column(length = 11)
	private String phone;
	
	/** 描述*/
	@Field
	@Column(length = 100)
	private String description;
	
	@Version
	private Integer version;
	
	@JsonSerialize(using = EnumSerializer.class)
	public static enum OrgOwnership{
		State("公办"), Civilian("民办");
		private String display;

		OrgOwnership(String display){
			this.display = display;
		}
		public String getDisplay() {
			return display;
		}
	}

	public Long getPkAllianceOrg() {
		return pkAllianceOrg;
	}

	public void setPkAllianceOrg(Long pkAllianceOrg) {
		this.pkAllianceOrg = pkAllianceOrg;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public OrgOwnership getOrgOwnership() {
		return orgOwnership;
	}

	public void setOrgOwnership(OrgOwnership orgOwnership) {
		this.orgOwnership = orgOwnership;
	}

	public AdministrativeDivision getAddress() {
		return address;
	}

	public void setAddress(AdministrativeDivision address) {
		this.address = address;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getPrincipal() {
		return principal;
	}

	public void setPrincipal(String principal) {
		this.principal = principal;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
}